package studentmansger;

import java.util.Objects;

public class ArrayUtils {
    private ArrayUtils() {

    }

    public static int findIndexById(Student[] students, int id, int count) {
        for (int i = 0; i < count; i++) {
            if (id == students[i].getId()) {
                return i;
            }
        }
        return -1;
    }

    public static int[] findIndexByName(Student[] students, String name, int count) {
        int[] arr = new int[count];
        int index = 0;
        for (int i = 0; i < count; i++) {
            if (Objects.equals(name, students[i].getName())) {
                arr[index++] = i;
            }
        }
        return arr;
    }

    public static  int[] findIndexByAge(Student[] students,int age,int count){
        int[] arr = new int[count];
        int index = 0;
        for (int i = 0; i < count; i++) {
            if(age == students[i].getAge()){
                System.out.println(students[i].getName()+" \t "+students[i].getAge()+" \t "+students[i].getSex());
                arr[index++] = i;
            }
        }
        return arr;
    }
    public static  int[] findIndexBySex(Student[] students,String sex,int count){
        int[] arr = new int[count];
        int index = 0;
        for (int i = 0; i < count; i++) {
            if(Objects.equals(sex, students[i].getSex())){
                arr[index++] = i;

            }
        }
        return arr;
    }
}